package com.ruoyi.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;

import com.ruoyi.business.domain.MobileExhibitorsType;
import com.ruoyi.business.mapper.MobileExhibitorsTypeMapper;
import com.ruoyi.business.service.IMobileExhibitorsTypeService;
import com.ruoyi.common.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 参展商分类Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-13
 */
@Service
public class MobileExhibitorsTypeServiceImpl extends ServiceImpl<MobileExhibitorsTypeMapper, MobileExhibitorsType> implements IMobileExhibitorsTypeService {

    @Autowired
    private MobileExhibitorsTypeMapper mobileExhibitorsTypeMapper;

    /**
     * 查询参展商分类
     *
     * @param id 参展商分类主键
     * @return 参展商分类
     */
    @Override
    public MobileExhibitorsType selectMobileExhibitorsTypeById(Long id) {
        return mobileExhibitorsTypeMapper.selectMobileExhibitorsTypeById(id);
    }

    /**
     * 查询参展商分类列表
     *
     * @param mobileExhibitorsType 参展商分类
     * @return 参展商分类
     */
    @Override
    public List<MobileExhibitorsType> selectMobileExhibitorsTypeList(MobileExhibitorsType mobileExhibitorsType) {
        return mobileExhibitorsTypeMapper.selectMobileExhibitorsTypeList(mobileExhibitorsType);
    }

    /**
     * 新增参展商分类
     *
     * @param mobileExhibitorsType 参展商分类
     * @return 结果
     */
    @Override
    public int insertMobileExhibitorsType(MobileExhibitorsType mobileExhibitorsType) {
                mobileExhibitorsType.setCreateTime(DateUtils.getNowDate());
            return mobileExhibitorsTypeMapper.insertMobileExhibitorsType(mobileExhibitorsType);
    }

    /**
     * 修改参展商分类
     *
     * @param mobileExhibitorsType 参展商分类
     * @return 结果
     */
    @Override
    public int updateMobileExhibitorsType(MobileExhibitorsType mobileExhibitorsType) {
                mobileExhibitorsType.setUpdateTime(DateUtils.getNowDate());
        return mobileExhibitorsTypeMapper.updateMobileExhibitorsType(mobileExhibitorsType);
    }

    /**
     * 批量删除参展商分类
     *
     * @param ids 需要删除的参展商分类主键
     * @return 结果
     */
    @Override
    public int deleteMobileExhibitorsTypeByIds(Long[] ids) {
        return mobileExhibitorsTypeMapper.deleteMobileExhibitorsTypeByIds(ids);
    }

    /**
     * 删除参展商分类信息
     *
     * @param id 参展商分类主键
     * @return 结果
     */
    @Override
    public int deleteMobileExhibitorsTypeById(Long id) {
        return mobileExhibitorsTypeMapper.deleteMobileExhibitorsTypeById(id);
    }

    /**
     * @param mobileExhibitorsType
     * @return java.util.List<com.ruoyi.business.domain.MobileExhibitorsType>
     * @Author liumaotong
     * @Description 参展商分类下拉列表
     * @Date 2024/6/17
     * @Param [mobileExhibitorsType]
     */
    @Override
    public List<MobileExhibitorsType> listForSelect(MobileExhibitorsType mobileExhibitorsType) {
        QueryWrapper<MobileExhibitorsType> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().select(MobileExhibitorsType::getId,MobileExhibitorsType::getName,MobileExhibitorsType::getSort);
        if(StringUtils.isNotBlank(mobileExhibitorsType.getName())){
            queryWrapper.lambda().like(MobileExhibitorsType::getName,mobileExhibitorsType.getName());
        }
        queryWrapper.lambda().orderByAsc(MobileExhibitorsType::getSort);
        return this.list(queryWrapper);
    }
}